﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Department_JobSet : System.Web.UI.Page
{
    private Srvtools.WebDataSet WMaster;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitializeComponent(false);

            Master.DataSource = WMaster;
            wgvMaster.Visible = false;

            
            MasterPage_MasterPage master = (MasterPage_MasterPage)this.Page.Master;
            master.HelpHref = "";
            master.PageName = "职位设置";
            master.PicUrl = "~/image/PageIcon/zhiwei.jpg";
            master.IntiBar();
        }
    }

    private void InitializeComponent(bool action)
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Department_JobSet));
        this.WMaster = new Srvtools.WebDataSet();
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).BeginInit();
        // 
        // WMaster
        // 
        this.WMaster.Active = action;
        this.WMaster.AlwaysClose = false;
        this.WMaster.PacketRecords = 100;
        this.WMaster.Position = -1;
        this.WMaster.RemoteName = "SDepartment.Job";
        this.WMaster.ServerModify = false;
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).EndInit();
    }

    protected void Search_Click(object sender, EventArgs e)
    {

       // Search.CssClass = "OnHover";

        string strDep = Depart.SelectDepmanetId;
        if (strDep == "")
        {
            return;
        }
        else if (strDep == "0")
        {
            strDep = "";
        }
        else
        {
            strDep = " And DepartmentId like ('" + strDep + "%')";
        }

        string strName = txtName.Text;
        if (strName != "")
        {
            strName = " And JobName like '%" + strName + "%' ";
        }
        else
        {
            strName = "";
        }
       

        string Status = ddlStatus.SelectedValue;
        if (Status == "-1")
        {
            Status = "";
        }
        else
        {
            Status = " And CompanyJob.Del = " + Status;
        }

        InitializeComponent(true);

        WMaster.SetWhere("1=1 " + strDep + Status + strName);

        Master.DataSource = WMaster;

        wgvMaster.Visible = true;
    }

    protected void wgvMaster_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRowView drv = (DataRowView)e.Row.DataItem;
            ((Label)e.Row.FindControl("Del")).Text = !Convert.ToBoolean(drv["Del"]) ? "<b style='color:red'>启用</b>" : "<font style='color:silver'>已作废</font>";

            ((ImageButton)e.Row.FindControl("imb")).Attributes.Add("onclick", "ymPrompt.win({title:'职位明细',message:'JobDetail.aspx?action=view&jid=" + drv["JobId"].ToString() + "',closeBtn:true,iframe:true,allowRightMenu:false,allowSelect:false});ymPrompt.max();return false");
        }
    }
}
